package com.frxuexi.shop2307.user

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.frxuexi.lib_base.mvvm.BaseActivity
import com.frxuexi.shop2307.R
import com.frxuexi.shop2307.adapter.ScoreAdapter
import com.frxuexi.shop2307.databinding.ActivityMyScoreBinding
import com.frxuexi.shop2307.shop.ShopViewModel
import dagger.hilt.android.AndroidEntryPoint

@Route(path = "/app/MyScoreActivity")
@AndroidEntryPoint
class MyScoreActivity : BaseActivity<ActivityMyScoreBinding,ShopViewModel>() {
    val scoreAdapter by lazy { ScoreAdapter() }
    override fun initData() {
        vm.scoreData.observe(this){
            scoreAdapter.addData(it.list)
            scoreAdapter.notifyDataSetChanged()
            val num=it.list.sumOf { it.number }
            binding.myScore.setText("${num}")
        }

    }

    override fun initView() {
        binding.myRv.apply {
            adapter=scoreAdapter
            layoutManager=LinearLayoutManager(this@MyScoreActivity)
        }
        vm.getScores()

        binding.myTab.apply {
            addTab(newTab().setText("分值明细"),true)
            addTab(newTab().setText("分值提升"))
        }
    }

}